<include file="Public:header" />
<!--主体-->
<div class="wrap">
    <div class="con-layer">
        <h3 style="margin-bottom:20px;">金币余额：{$user_yue}金币</h3>
        <table width="90%" border="0" cellspacing="0" cellpadding="0">
            <tr class="title">
                <td><a class="active" href="javascript:;" onClick="needgoldsnum(50,this)">50元红包</a></td>
                <td><a href="javascript:;" onClick="needgoldsnum(100,this)">100元红包</a></td>
                <td><a class="moreh" href="javascript:;" onClick="needgoldsnum(101,this)">100元以上</a></td>
            </tr>
            <tr class="title more_jine" style="display:none;">
                <td colspan="1">输入金额</td>
                <td colspan="3">
                    <input type="number" value="" class="text-m paymorenum_input" id="input3" style="width:100%;"> </td>
            </tr>
        </table>
        <p class="margintop">需要：
            <font class="needgoldsnum">5700</font>金币
        </p>
        <p class="hmore" style="display:none;">请输入100以上50的倍数</p>
    </div>
    <a class="btn-dota tobuygo_btn" href="./index.php?a=tobuygo&m=index&bnum=50">立即兑换</a>
</div>
<script type="text/javascript">
function needgoldsnum(t, obj) {
    $(".title a.active").removeClass();
    $(obj).addClass("active");
    if (t == 50) {
        $(".needgoldsnum").text(5700);
        $(".more_jine").hide();
        $(".tobuygo_btn").attr("href", "./index.php?a=tobuygo&m=index&bnum=" + 50 + "");
    }
    if (t == 100) {
        $(".needgoldsnum").text(11000);
        $(".more_jine").hide();
        $(".tobuygo_btn").attr("href", "./index.php?a=tobuygo&m=index&bnum=" + 100 + "");
    }
    if (t >= 101) {
        $(".needgoldsnum").text("");
        $(".more_jine").show();
        $(".hmore").show();
        $(".tobuygo_btn").attr("href", "./index.php?a=tobuygo&m=index&bnum=" + t + "");
    }
}
$(function() {
    $('.paymorenum_input').bind('input propertychange', function() {
        var morenum = $(this).val();
        if (morenum > 100) {
            var moregolds = Math.floor(morenum * 110);
            $(".needgoldsnum").text(moregolds);
            $(".tobuygo_btn").attr("href", "./index.php?a=tobuygo&m=index&bnum=" + morenum + "");
        } else if (morenum < 0) {
            $(this).val(100);
            var moregolds = Math.floor(100 * 110);
            $(".needgoldsnum").text(moregolds);
            $(".tobuygo_btn").attr("href", "./index.php?a=tobuygo&m=index&bnum=" + 100 + "");

        }
    });
    $(".tobuygo_btn").click(function() {
        var a = $("#input3").val();
        if($(".moreh").hasClass("active")){
        if (a % 50 === 0) {
            if(a>=100){
            $(".tobuygo_btn").attr("href", "./index.php?a=tobuygo&m=index&bnum=" + a + "");
        }
            else if(a<100){
                alert("输入的数必须大于100,请重新输入！");
                $(".tobuygo_btn").attr("href", "#");
            }
        } else {
            alert("不是50的倍数,请重新输入！");
            $(".tobuygo_btn").attr("href", "#");
        }
    }
    })
});
</script>
<include file="Public:footer" />
